FROM alpine:3.20.3 AS rootfs-stage

# environment
ENV REL=v3.20
ENV ARCH=x86_64
# ENV MIRROR=http://dl-cdn.alpinelinux.org/alpine
ENV MIRROR=https://mirrors.ustc.edu.cn/alpine
ENV PACKAGES=alpine-baselayout,\
alpine-keys,\
apk-tools,\
busybox,\
libc-utils,\
bash,\
xz,\
alpine-release,\
ca-certificates,\
catatonit,\
coreutils,\
curl,\
findutils,\
jq,\
netcat-openbsd,\
procps-ng,\
shadow,\
tzdata

# ARG BUILD_DATE
# ARG VERSION
# ARG MODS_VERSION="v3"
# ARG PKG_INST_VERSION="v1"
# ARG LSIOWN_VERSION="v1"
# LABEL build_version="lkatzey.sdf.org version:- ${VERSION} Build-date:- ${BUILD_DATE}"
# LABEL maintainer="TheLamer"

# environment variables
ENV PS1="$(whoami)@$(hostname):$(pwd)\\$ " \
  HOME="/root" \
  TERM="xterm"

# build rootfs
RUN \
  mkdir -p "/etc/apk" && \
  { \
    echo "$MIRROR/$REL/main"; \
    echo "$MIRROR/$REL/community"; \
  } > "/etc/apk/repositories" && \
  echo "**** install runtime packages ****\n" && \
  apk --root "/" --no-cache --keys-dir /etc/apk/keys add --arch $ARCH --initdb ${PACKAGES//,/ } && \
  sed -i -e 's/^root::/root:!:/' /etc/shadow

# install packages
RUN \
  echo "**** create object user and make our folders ****\n" && \
  groupmod -g 1000 users && \
  useradd -u 1100 -U -d /config -s /bin/false object && \
  usermod -G users object && \
  mkdir -p \
    /app \
    /config \
    /defaults && \
  echo "**** cleanup ****" && \
  rm -rf \
    /tmp/*

# add local files
#COPY root/ /

# CMD ["/bin/sh"]

ENTRYPOINT ["/sbin/init"]

